package com.qf.mybatis01.utils;

import com.qf.mybatis01.entity.Book;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

public class BookWriter {
    public static void writerBooks(List<Book> list) throws IOException {
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\2203-maven\\mybatis02\\20221222work\\bookTest.csv",true));
        for (Book book : list) {
            //book转成字符串
            String s = book.toCSVString();
            bw.write(s);
            bw.newLine();
        }
        //关流
        bw.close();
    }
}
